const http = require('http')
const fs = require('fs')

http
  .createServer(function(request, repsone) {
    if (request.url === '/') {
      const body = fs.readFileSync('./index.html', 'utf-8')
      repsone.writeHead(200, {
        'Content-Type': 'text/html'
      })
      repsone.end(body)
    } else {
      const img = fs.readFileSync('./polo.jpg')
      repsone.writeHead(200, {
        'Content-Type': 'image/jpg'
        // 'connection': 'keep-alive'
      })
      repsone.end(img)
    }
  })
  .listen(8888)
console.log('server at 8888')
